{extend name="ace/layout/master/detail" /}

{block name="title"}系统公告管理{/block}
{block name="page-title"}系统公告{/block}

{block name="content"}
    <input name="notice_id" class="form-control" type="hidden" value="{if $detail}{$detail->notice_id}{/if}" />
    <div class="form-group">
        <label class="col-sm-3 control-label no-padding-right"> 系统公告类型：</label>
        <div class="col-sm-9">
            <select name="notice_type" class="col-xs-10 col-sm-5" onchange="changeNoticeType(this)" required>
                {if !empty($notice_types)}
                    {foreach $notice_types as $key => $val}
                        <option value="{$key}"
                                {if $detail && $detail->notice_type == $key}selected{/if}
                            > {$val} </option>
                    {/foreach}
                {/if}
            </select>
        </div>
    </div>
    <div class="space-4"></div>
    <div class="form-group">
        <label class="col-sm-3 control-label no-padding-right"> 公告标题： </label>
        <div class="col-sm-9">
            <input type="text" name="notice_title" placeholder="输入公告标题" class="col-xs-10 col-sm-5" required="" value="{if $detail}{$detail->notice_title}{/if}" />
        </div>
    </div>
    <div class="space-4 wedding-role hidden"></div>
    <div class="form-group wedding-role hidden">
        <label class="col-sm-3 control-label no-padding-right"> 请选择角色：</label>
        <div class="col-sm-9">
            <select name="wedding_role" class="col-xs-10 col-sm-5" required>
                <option value="0"
                        {if $detail && $detail->wedding_role == 0}selected{/if}
                    > 请选择角色 </option>
                {if !empty($wedding_roles)}
                {foreach $wedding_roles as $val}
                <option value="{$val['role_id']}"
                        {if $detail && $detail->wedding_role == $val['role_id']}selected{/if}
                    > {$val['role_name']} </option>
                {if !empty($val['_child'])}
                {foreach $val['_child'] as $child}
                <option value="{$child['role_id']}"
                        {if $detail && $detail->wedding_role == $child['role_id']}selected{/if}
                    > ├─{$child['role_name']} </option>
                {/foreach}
                {/if}
                {/foreach}
                {/if}
            </select>
        </div>
    </div>
    <div class="space-4"></div>
    <div class="form-group">
        <label class="col-sm-3 control-label no-padding-right"> 公告内容：</label>
        <div class="col-sm-7">
            <!-- 加载编辑器的容器 -->
            <script id="ue-container" name="notice_content" type="text/plain">{if $detail}{:html_entity_decode($detail->notice_content)}{/if}</script>
        </div>
    </div>
{/block}

{block name="script"}
{include file="ace/layout:ueditor" /}
<script type="text/javascript">
    window.onload = function () {
        closeLayerLoading(closeAllLayer);
        uediotr();
    }

    function changeNoticeType(_this) {
        console.log($(_this).val());
        if ($(_this).val() == 1){
            $('div.wedding-role').removeClass('hidden');
        }else{
            $('div.wedding-role').addClass('hidden');
        }
    }
</script>
{/block}